package com.starview.star.operators.string;

import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.star.compiler.standard.StandardNames;
import com.starview.star.compiler.transform.OverLoader;
import com.starview.star.operators.Builtin;
import com.starview.star.operators.Intrinsics;
import com.starview.star.operators.string.runtime.StringCompare.StringEQ;
import com.starview.star.operators.string.runtime.StringCompare.StringGE;
import com.starview.star.operators.string.runtime.StringCompare.StringGT;
import com.starview.star.operators.string.runtime.StringCompare.StringLE;
import com.starview.star.operators.string.runtime.StringCompare.StringLT;
import com.starview.star.operators.string.runtime.StringCompare.StringNE;



public class StringCompare extends Builtin
{
  public static final String STRING_EQ = "__string_eq";
  
  private static final IType rawStringStype = StandardTypes.rawStringType;

  private StringCompare(String name, Class<?> implClass)
  {
    super(name, TypeUtils.functionType(rawStringStype, rawStringStype, StandardTypes.booleanType), implClass);
  }

  public static void declare(Intrinsics cxt)
  {
    String equality = StandardNames.EQUALITY;
    OverLoader.declarePrimitiveImplementation(equality, StandardNames.EQUAL, rawStringStype, STRING_EQ);
    cxt.declareBuiltin(new StringCompare(STRING_EQ, StringEQ.class));

    cxt.declareBuiltin(new StringCompare("__string_ne", StringNE.class));
    OverLoader.declarePrimitiveImplementation(equality, StandardNames.NOT_EQUAL, rawStringStype, "__string_ne");

    cxt.declareBuiltin(new StringCompare("__string_lt", StringLT.class));
    cxt.declareBuiltin(new StringCompare("__string_le", StringLE.class));
    cxt.declareBuiltin(new StringCompare("__string_ge", StringGE.class));
    cxt.declareBuiltin(new StringCompare("__string_gt", StringGT.class));
  }
}